/**
 * Copyright 2014 the original author or authors. All rights reserved.
 */
package com.visionet.security.domain.entity;

import java.util.Set;

import javax.persistence.*;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.visionet.jumper.core.domain.entity.BaseEntity;

/**
 * 角色信息
 *
 * @author suxiaojing
 * @date 
 * @since 0.0.1
 */
@Entity(name="Role")
@Table(name="t_role")
@DynamicInsert
@DynamicUpdate
public class Role extends BaseEntity {
	private static final long serialVersionUID = 7940296120104921830L;

	private String code; //角色编码

	private String name; //角色名称

	private String description; //角色描述

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "t_role_roles",
			   joinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "id") },
			   inverseJoinColumns = { @JoinColumn(name = "sub_role_id", referencedColumnName = "id") }
			   )
	private Set<Role> roles;

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "t_role_privilege",
			   joinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "id") },
			   inverseJoinColumns = { @JoinColumn(name = "privilege_id", referencedColumnName = "id") }
			   )
	private Set<Privilege> privileges;

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the roles
	 */
	public Set<Role> getRoles() {
		return roles;
	}

	/**
	 * @param roles
	 *            the roles to set
	 */
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	/**
	 * @return the privileges
	 */
	public Set<Privilege> getPrivileges() {
		return privileges;
	}

	/**
	 * @param privileges
	 *            the privileges to set
	 */
	public void setPrivileges(Set<Privilege> privileges) {
		this.privileges = privileges;
	}

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code
	 *            the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

}